﻿using System;
using Autodesk.Revit.Attributes;
using Autodesk.Revit.DB;
using Autodesk.Revit.UI;
using Autodesk.Revit.UI.Selection;

namespace FetchDataCompare
{
	[Transaction(TransactionMode.Manual)]
	internal class TestCmd : IExternalCommand
	{
		public Result Execute(ExternalCommandData commandData, ref string message, ElementSet elements)
		{
			UIApplication application = commandData.Application;
			UIDocument activeUIDocument = application.ActiveUIDocument;
			Document document = activeUIDocument.Document;
			Selection selection = activeUIDocument.Selection;
			try
			{
				for (;;)
				{
					Reference reference = selection.PickObject(Autodesk.Revit.UI.Selection.ObjectType.Element, "请选择标注对象");
					Dimension dimension = document.GetElement(reference) as Dimension;
					Curve curve = dimension.Curve;
					TaskDialog.Show("标注信息", curve.GetEndPoint(0).ToString() + ";" + curve.GetEndPoint(1).ToString());
				}
			}
			catch (Exception)
			{
			}
			return Autodesk.Revit.UI.Result.Succeeded;
		}
	}
}
